/** @file vector2.h
  *
  * Naglowek klasy wektora.
  */

#ifndef VECTOR2_H_INCLUDED
#define VECTOR2_H_INCLUDED

#include <cmath>
#include <fstream>

/**
 * @class Vector2
 * @brief Dwuwymiarowy wektor.
 *
 */
class Vector2 {
public:

  float x, y; ///< Wspolrzedne
  Vector2() : x(0), y(0) {}
  Vector2(float a, float b) : x(a), y(b) {}
  Vector2(const Vector2 &f) : x(f.x), y(f.y) {}

  const float mag() { return sqrt(pow(x, 2) + pow(y, 2)); }

  Vector2& operator=(const Vector2 &b){
    if(&b == this) return *this;
    x= b.x;
    y= b.y;
    return *this;
  }
};

const float dist(const Vector2 &a, const Vector2 &b);
const float dotp(const Vector2 &a, const Vector2 &b);

const Vector2 operator+(const Vector2 &a, const Vector2 &b);
const Vector2 operator-(const Vector2 &a, const Vector2 &b);
const Vector2 operator*(const Vector2 &a, const float &b);
const Vector2 operator/(const Vector2 &a, const float &b);

Vector2& operator+=(Vector2 &a, const Vector2 &b);
Vector2& operator-=(Vector2 &a, const Vector2 &b);
Vector2& operator*=(Vector2 &a, const float &b);
Vector2& operator/=(Vector2 &a, const float &b);

bool operator==(Vector2 &a, const Vector2 &b);

std::ofstream& operator<<(std::ofstream &o, const Vector2 &a);

#endif // VECTOR2_H_INCLUDED
